﻿@using tour.szhome.common;
@{
    ViewBag.Title = ViewBag.ID != 0 ? "编辑项目" : "添加项目";
}
<h3>@(ViewBag.ID != 0 ? "编辑项目" : "添加项目")</h3>
<div style="padding:5px;">
    <form>
    <hr />
    <table class="tb">
        <tbody>
            <tr>
                <td align="center"><span>项目名称：</span></td>
                <input type="hidden" name="XMID" value="@Model.XMID" />
                <td><input name="XMMC" type="text" id="txtXMMC" value="@Model.XMMC">*(50)</td>
                <td align="center"><span>车位数：</span></td>
                <td><input name="CWS" type="text" id="txtCWS" value="@Model.CWS">(整数)</td>
            </tr>
            <tr>
                <td align="center"><span>项目类别：</span></td>
                <td>
                    <table id="chklXMLB" border="0" style="height:80px;width:300px;">
                        <tbody>
                            <tr>
	                            <td><input id="ck1" type="checkbox" name="ckbox"><label for="ck1">滨海资源 </label></td>
                                <td><input id="ck2" type="checkbox" name="ckbox"><label for="ck2">湖泊资源</label></td>
                                <td><input id="ck3" type="checkbox" name="ckbox"><label for="ck3">高尔夫资源</label></td>
                            </tr>
                            <tr>
	                            <td><input id="ck4" type="checkbox" name="ckbox"><label for="ck4">温泉资源</label></td>
                                <td><input id="ck5" type="checkbox" name="ckbox"><label for="ck5">山林资源</label></td>
                                <td><input id="ck6" type="checkbox" name="ckbox"><label for="ck6">主题公园资源</label></td>
                            </tr>
                        </tbody>
                        <input id="ckxmlb" name="XMLB" value="@Model.XMLB" />
                    </table>
                </td>
                <td align="center"><span>建筑面积：</span></td>
                <td><input type="text" id="txtJZMJ" name="JZMJ" style="width:300px;" value="@Model.JZMJ">(30)</td>
            </tr>
            <tr>
                <td align="center"><span>项目地址：</span></td>
                <td><textarea rows="2" cols="20" id="txtXMDZ" name="XMDZ" style="height:44px;width:300px;">@Html.Raw(Model.XMDZ)</textarea>(30)</td>
                <td align="center"><span>占地面积：</span></td>
                <td><input type="text" id="txtZDMJ" name="ZDMJ" style="width:300px;" value="@Model.ZDMJ">(30)</td>
            </tr>
            <tr>
                <td align="center"><span>项目特色：</span></td>
                <td><textarea rows="2" cols="20" id="txtXMTS" name="XMTS" style="height:44px;width:300px;">@Html.Raw(Model.XMTS)</textarea>(&lt;40)</td>
                <td align="center"><span>预售许可证：</span></td>
                <td><input type="text" id="txtYSXKZ" name="YSXKZ" style="width:300px;" value="@Model.YSXKZ">(30)</td>
            </tr>
            <tr>
                <td>&nbsp;</td>
                <td>&nbsp;</td>
                <td align="center"><span>工程承建商：</span></td>
                <td><input type="text" id="txtGCCJS" name="GCCJS" style="height:22px;width:300px;" value="@Model.GCCJS">(30)</td>
            </tr>
            <tr>
                <td align="center"><span>开盘时间：</span></td>
                <td><input type="text" id="txtKPSJ" name="KPSJ" value="@Model.KPSJ">(yyyy-MM-dd或待定)</td>
                <td align="center"><span>开发商：</span></td>
                <td><input type="text" id="txtKFS" name="KFS" style="width:300px;" value="@Model.KFS">(30)</td>
            </tr>
            <tr>
                <td align="center"><br><span>入住时间：</span></td>
                <td><br><input type="text" id="txtRZSJ" name="RZSJ" value="@Model.RZSJ">(yyyy-MM-dd或待定)</td>
                <td align="center"><span>物业公司：</span></td>
                <td><input type="text" id="txtWYGS" name="WYGS" style="width:300px;" value="@Model.WYGS">(30)</td>
            </tr>
            <tr>
                <td align="center"><span>售楼处咨询电话：</span></td>
                <td><input type="text" id="txtZXDH" name="ZXDH" value="@Model.ZXDH"></td>
                <td align="center"><span>物业类型：</span></td>
                <td><input type="text" id="txtWYLX" name="WYLX" style="width:300px;"  value="@Model.WYLX">(&lt;20)</td>
            </tr>
            <tr>
                <td align="center"><span>土地年限：</span></td>
                <td><input type="text" id="txtTDNX" name="TDNX" value="@Model.TDNX">（整数）</td>
                <td align="center"><span>物业费：</span></td>
                <td><input type="text" id="txtWYF" name="WYF" style="width:300px;" value="@Model.WYF">(30)</td>
            </tr>
            <tr>
                <td align="center"><span>绿化率：</span></td>
                <td><input name="txtLHL" type="text" id="txtLHL" name="LHL" value="@Model.LHL">（百分数）</td>
                <td align="center"><span>园林设计：</span></td>
                <td><textarea rows="2" cols="20" id="txtYLSJ" name="YLSJ" style="height:44px;width:300px;">@Html.Raw(Model.YLSJ)</textarea>(50)</td>
            </tr>
            <tr>
                <td align="center"><span>容积率：</span></td>
                <td><input type="text" id="txtRJL" name="RJL" value="@Model.RJL">（小数）</td>
                <td align="center"><span>建筑设计：</span></td>
                <td><textarea rows="2" cols="20" id="txtJZSJ" name="JZSJ" style="height:44px;width:300px;">@Html.Raw(Model.JZSJ)</textarea>(50)</td>
            </tr>
            <tr>
                <td align="center"><span>总户数：</span></td>
                <td><input type="text" id="txtZHS" name="ZHS" value="@Model.ZHS">（整数）</td>
                <td align="center"><span>均价：</span></td>
                <td><input type="text" id="txtJJ" name="JJ" value="@Model.JJ">元/平方米（整数）</td>
            </tr>
        </tbody>
    </table>
    <hr />
    <table class="tb">
        <tbody>
            <tr>
                <td align="center"><span>团购地址：</span></td>
                <td><input type="text" id="txtTGDZ" name="TGDZ" style="width:680px;" value="@Html.Raw(Model.TGDZ)"></td>
            </tr>
            <tr>
                <td align="center"><span>户型介绍：</span></td>
                <td><textarea rows="2" cols="20" id="txtHXJS" name="HXJS" style="height:44px;width:680px;">@Html.Raw(Model.HXJS)</textarea>(500)</td>
            </tr>
            <tr>
                <td align="center"><span>配套交通1:</span></td>
                <td><textarea rows="2" cols="20" id="txtPTJT1" name="PTJT1" style="height:44px;width:680px;">@Html.Raw(Model.PTJT1)</textarea>(100)</td>
            </tr>
            <tr>
                <td align="center"><span>配套交通2:</span></td>
                <td><textarea rows="2" cols="20" id="txtPTJT2" name="PTJT2" style="height:44px;width:680px;">@Html.Raw(Model.PTJT2)</textarea>(200)</td>
            </tr>
            <tr>
                <td align="center"><span>配套交通3:</span></td>
                <td><textarea rows="2" cols="20" id="txtPTJT3" name="PTJT3" style="height:44px;width:680px;">@Html.Raw(Model.PTJT3)</textarea>(100)</td>
            </tr>
            <tr>
                <td align="center"><span>配套交通4:</span></td>
                <td><textarea rows="2" cols="20" id="txtPTJT4" name="PTJT4" style="height:44px;width:680px;">@Html.Raw(Model.PTJT4)</textarea>(200)</td>
            </tr>
            <tr>
                <td align="center"><span>项目详情：</span></td>
                <td><textarea rows="2" cols="20" id="txtXMXQ" name="XMXQ" style="height:100px;width:680px;">@Html.Raw(Model.XMXQ)</textarea>(4000)</td>
            </tr>
                <tr>
                <td align="center"><span>价格说明：</span></td>
                <td><textarea rows="2" cols="20" id="txtJGSM" name="JGSM" style="height:66px;width:680px;">@HttpUtility.HtmlDecode(Model.JGSM)</textarea>(200)</td>
            </tr>
            <tr>
                <td align="center"><span>项目地图介绍：</span></td>
                <td><textarea rows="2" cols="20" id="txtJTDTJS" name="JTDTJS" style="height:75px;width:680px;">@Html.Raw(Model.JTDTJS)</textarea>(4000)</td>
            </tr>
            <tr>
                <td align="center"><span>区域介绍：</span></td>
                <td><textarea rows="2" cols="20" id="txtQYJS" name="QYJS" style="height:100px;width:680px;">@Html.Raw(Model.QYJS)</textarea>(4000)</td>
            </tr>
            <tr>
                <td align="center"><span>项目交通：</span></td>
                <td><textarea rows="2" cols="20" id="txtXMJT" name="XMJT" style="height:100px;width:680px;">@Html.Raw(Model.XMJT)</textarea>(4000)</td>
            </tr>
            <tr>
                <td align="center"><span>项目配套：</span></td>
                <td><textarea rows="2" cols="20" id="txtXMPT" name="XMPT" style="height:100px;width:680px;">@Html.Raw(Model.XMPT)</textarea>(4000)</td>
            </tr>
            <tr>
                <td align="center"><span>特色内容：</span></td>
                <td><textarea rows="2" cols="20" id="txtTSNR" name="TSNR" style="height:100px;width:680px;">@Html.Raw(Model.TSNR)</textarea>(4000)</td>
            </tr>
        </tbody>
    </table>
    <hr />
    <table class="tb" style="text-align :center;">
        <tbody>
            <tr>
                <td>
                    <input type="button" value="@(ViewBag.ID != 0 ? "修改" : "添加")" id="btnUpdate" style="width:60px;">
                    <input type="button" value="返回" onclick="javascript: window.history.go(-1);" style="width:60px;">
                </td>
            </tr>
        </tbody>
    </table>
    <hr />
    <table class="tb">
        <tbody>
            <tr>
                <td align="center"><span>特色图：</span></td>
                <td>
                    <input type="file" name="upload" id="upload1" />
                    <input id="ImgV1" type="hidden" name="TST" value="@Model.TST" />
                    <br>
                    <img id="imgTST" src=@(ViewBag.ID > 0 ? ViewBag.uploadAddress + ViewBag.Folder + Model.TST : CommPath.FileImport("manage/images/zanwutupian.gif")) style="height:100px;width:100px;border-width:0px;">       
                </td>
                <td align="center"><span>交通地图：</span></td>
                <td>
                    <input type="file" name="upload" id="upload2" />
                    <input id="ImgV2" type="hidden" name="JTDT" value="@Model.JTDT" />
                    <br>
                    <img id="imgJTDT" src=@(ViewBag.ID > 0 ? ViewBag.uploadAddress + ViewBag.Folder + Model.JTDT : CommPath.FileImport("manage/images/zanwutupian.gif")) style="height:100px;width:100px;border-width:0px;">        
                </td>
            </tr>
            <tr>
                <td align="center"><span>项目列表图：</span></td>
                <td>
                    <input type="file" name="upload" id="upload3" />
                    <input id="ImgV3" type="hidden" name="XMLBT" value="@Model.XMLBT" />
                    <br>
                    <img id="imgXMLBT" src=@(ViewBag.ID > 0 ? ViewBag.uploadAddress + ViewBag.Folder + Model.XMLBT : CommPath.FileImport("manage/images/zanwutupian.gif")) style="height:100px;width:100px;border-width:0px;">       
                </td>
                <td align="center"><span>项目全景图：</span></td>
                <td>
                    <input type="file" name="upload" id="upload4" />
                    <input id="ImgV4" type="hidden" name="XMQJT" value="@Model.XMQJT" />
                    <br>
                    <img id="imgXMQJT" src=@(ViewBag.ID > 0 ? ViewBag.uploadAddress + ViewBag.Folder + Model.XMQJT : CommPath.FileImport("manage/images/zanwutupian.gif")) style="height:100px;width:100px;border-width:0px;">      
                </td>
            </tr>
            <tr>
                <td align="center"><span>项目地图：</span></td>
                <td>
                    <input type="file" name="upload" id="upload5" />
                    <input id="ImgV5" type="hidden" name="XMDT" value="@Model.XMDT" />
                    <br>
                    <img id="imgXMDT" src=@(ViewBag.ID > 0 ? ViewBag.uploadAddress + ViewBag.Folder + Model.XMDT : CommPath.FileImport("manage/images/zanwutupian.gif")) style="height:100px;width:100px;border-width:0px;">       
                </td>
                <td>&nbsp;</td>
                <td>（无图片显示则没有添加图片；继续上传则覆盖原有图片。）</td>
            </tr>
        </tbody>
    </table>
    <hr />
    </form>
</div>
@CommPath.StyleImport("public/plug-in/uploadify/uploadify.css")
@CommPath.ScriptImport("public/plug-in/uploadify/jquery.uploadify-3.2.js")
<script type="text/javascript">
    $(function () {
        //ckbox交互处理
        $("input:checkbox").each(function () {
            if ($(this).next().html() == "@Model.XMLB") {
                $(this).attr("checked", "checked");
            }
        })

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload1').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData': { 'f': "@ViewBag.Folder" },
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                $("#imgTST").attr("src", "@ViewBag.uploadAddress" + "@ViewBag.Folder" + data);
                $("#ImgV1").val(data);   //要入库的路径
                
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload2').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData': { 'f': "@ViewBag.Folder" },
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                $("#imgJTDT").attr("src", "@ViewBag.uploadAddress" + "@ViewBag.Folder" + data);
                $("#ImgV2").val(data);   //要入库的路径
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload3').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData': { 'f': "@ViewBag.Folder" },
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                $("#imgXMLBT").attr("src", "@ViewBag.uploadAddress" + "@ViewBag.Folder" + data);
                $("#ImgV3").val(data);   //要入库的路径
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload4').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData': { 'f': "@ViewBag.Folder" },
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                $("#imgXMQJT").attr("src", "@ViewBag.uploadAddress" + "@ViewBag.Folder" + data);
                $("#ImgV4").val(data);   //要入库的路径
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });

        // 这里暂时不知道怎么处理好，先一个个监听吧
        $('#upload5').uploadify({
            'buttonText': '选择文件',
            'buttonClass': 'browser',
            'width': 90,
            'height': 25,
            'formData': { 'f': "@ViewBag.Folder" },
            'fileTypeExts': '*.jpg;*.png;*.bmp;*.gif;',
            'swf': '@CommPath.FileImport("public/plug-in/uploadify/uploadify.swf")',
            'uploader': '/manage/help/UploadFiles',
            'onUploadSuccess': function (file, data, response) {
                $("#imgXMDT").attr("src", "@ViewBag.uploadAddress" + "@ViewBag.Folder" + data);
                $("#ImgV5").val(data);   //要入库的路径
            },
            'onSelectError': function (file, errorCode, errorMsg) {
                switch (errorCode) {

                    case -110:
                        alert("文件 [" + file.name + "] 大小超出系统限制的" + (1024 * 1024 * 5) + "大小！");
                        break;
                    case -120:
                        alert("文件 [" + file.name + "] 大小异常！");
                        break;
                    case -130:
                        alert("文件 [" + file.name + "] 类型不正确！");
                        break;
                }
            }
        });
    });

    $("#btnUpdate").bind("click", function () {
        edit();
    });

    function edit() {
        var txtXMMC = $('#txtXMMC').val();
        if (txtXMMC == "") {
            dlg.Msg.Inf("项目名称不能未空");
            $('#txtXMMC').focus();
            return;
        }

        var XMLB = "";
        $("input:checkbox").each(function () {
            if ($(this).attr("checked") == "checked") {
                XMLB += $(this).next().html();
            }
        })
        if (XMLB.length > 5) {
            $('#ck1').focus();
            dlg.Msg.Inf("现在只能选择一种项目类别");
            return;
        }

        $("#ckxmlb").val(XMLB);

        var txtJJ = $('#txtXMDZ').val();
        if (txtJJ == "") {
            dlg.Msg.Inf("项目地址不能未空");
            $('#txtXMDZ').focus();
            return;
        }

        var txtJJ = $('#txtXMTS').val();
        if (txtJJ == "") {
            dlg.Msg.Inf("项目特色不能未空");
            $('#txtXMTS').focus();
            return;
        }

        var txtJJ = $('#txtJJ').val();
        if (txtJJ == "") {
            dlg.Msg.Inf("项目均价不能未空");
            $('#txtJJ').focus();
            return;
        }
        
        $.ajax({
            type: "post",
            url: "/manage/project/json_edit",
            data: $("form").serialize(),
            dataType: "json",
            timeout: 30000, //over time：30s
            beforeSend: function () {
                window.top.qibu.msgbox.loading("正在提交申请，请稍后... ...");
            },
            success: function (data) {
                window.top.qibu.msgbox.hide();
                if (data) {
                    dlg.Msg.Inf("操作成功");
                    setTimeout("window.history.go(-1)", 1000);
                }
                else {
                    dlg.Msg.Err("操作失败");
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                window.top.qibu.msgbox.hide();
                dlg.Msg.Err(errorThrown);
            }
        });
    }
</script>